package cn.edu.nju.software.cdiy.util;

import java.util.ArrayList;
import java.util.List;

import cn.edu.nju.software.cdiy.bean.MainBoard;

public class Pager<T> {
	public static int getMax(int page){
		int maxNum=0;
		if(page%Constant.PAGE_RETURN==0){
			maxNum=page*Constant.PAGE_LENGTH;
		}else maxNum = (page/Constant.PAGE_RETURN+1)*Constant.PAGE_LENGTH*Constant.PAGE_RETURN;
		return maxNum;
	}

	public static int getMin(int max){
		return max-Constant.PAGE_LENGTH*Constant.PAGE_RETURN+1;
	}
	
	public List<T> getPageList(List<T> list,int min,int max){
		ArrayList<T> returnList = new ArrayList<T>();
		for(int i=0;i<max;i++){
			if(i==list.size()) break;
			if(i<min-1) continue;
			else returnList.add(list.get(i));
		}
		
		return returnList;
	}

}
